<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>CurrencyConverter HOWTO</title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/styles.css" />
  </head>

  <body>

    <div class="title">
      <h1>Building the Application</h1>
    </div>

    <div class="body-text">
      <p>Both the user interface and the behavior of the
      CurrencyConverter are complete now. All that remains for us to
      do is to build the application executable into a Cocoa
      application bundle. Apple's tutorial relies on XCode to build
      the application from Objective-C source files; we will use the
      Clozure CL IDE to build it from our Lisp source file.</p>

      <p>We build the application using the optional
      BUILD-APPLICATION feature, distributed as part of Clozure CL. The
      steps to build the Cocoa application are:</p>

      <ol>
        <li><p>Load the application code into the IDE</p></li>
        <li><p>Load the BUILD_APPLICATION feature</p></li>
        <li><p>Run BUILD_APPLICATION with the proper arguments</p></li>
      </ol>

      <p>This sequence of steps causes Clozure CL to construct a Cocoa
      application bundle and write out the application executable to
      it, then quit. If all goes well, you should be able to run the
      application by double-clicking it, and use the UI you built in
      InterfaceBuilder to convert currencies.</p>
    </div>

    <div class="section-head">
      <h2>Building the Application, Step-by-Step</h2>
    </div>

    <div class="body-text">
      <ol>
        <li><p>Launch the Clozure CL IDE. It's safest to build the
        application with a fresh IDE session, so if you have it
        running, you may wish to quit and relaunch before following
        the rest of the steps.</p></li>

        <li><p>For convenience, set the working directory to your
        "currency-converter" folder. For example, you can do
        something like this (using your pathnames in place of mine, of
        course:):</p>
          <p><code>(setf (current-directory) "/Users/mikel/Valise/clozure/openmcl/example-code/currency-converter/")</code></p>
        </li>

        <li><p>Load the application code:</p>
          <p><code>(load "currency-converter")</code></p>
        </li>

        <li><p>Load the BUILD-APPLICATION feature:</p>
          <p><code>(require "build-application")</code></p>
        </li>

        <li><p>Run BUILD-APPLICATION (be sure to correct the pathname
        to your CurrencyConverter nibfile. It is safest to use a full,
        absolute pathname&mdash;not the relative pathname you see
        below):</p>
          <p><pre>
(ccl::build-application :name "CurrencyConverter"
                        :main-nib-name "CurrencyConverter"
                        :nibfiles 
  '(#P"currency-converter/CurrencyConverter.nib"))</pre></p>
        </li>
      </ol>

      <p>By default, BUILD-APPLICATION constructs the application
      bundle in the current working directory. If you followed the
      instructions here, that means it will build
      CurrencyConverter.app in your currency-converter folder. You
      can control where BUILD-APPLICATION puts the application bundle
      by passing a pathname as the value of the keyword argument
      :DIRECTORY, like so:</p>

          <p><pre>
(ccl::build-application :name "CurrencyConverter"
                        :directory #P"/Users/mikel/Desktop/"
                        :main-nib-name "CurrencyConverter"
                        :nibfiles 
  '(#P"currency-converter/CurrencyConverter.nib"))</pre></p>

      <p>If all goes well, BUILD-APPLICATION constructs an
        application bundle, copies "CurrencyConverter.nib" into it,
        writes the application executable, and quits. You should now
        be able to launch CurrencyConverter.app by double-clicking
        the application icon:</p>

      <div class="subtitle">
        <img src="../images/cc1.jpg"alt="" 
             border='0'/>
      </div>

      <p>CurrencyConverter.app launches and displays your user
      interface, which you can then use to convert currencies:</p>

      <div class="subtitle">
        <img src="../images/cc2.jpg"alt="" 
             border='0'/>
      </div>


    </div>

    <div class="section-head">
      <h2>Correcting the Application Name</h2>
    </div>

    <div class="body-text">
      <p>You'll notice when you run the application that, even though
      you named it CurrencyConverter, the name in the main menu
      appears as "Clozure CL". That's because OS X takes the
      application's name, not from the application bundle's name, nor
      from the running code, but from an InfoPlist.strings file hidden
      inside the application bundle. To make the name appear
      correctly in the running application, you need to edit the file</p>

      <p>CurrencyConverter.app/Contents/Resources/English.lproj/InfoPlist.strings</p>

      <p>Find the entry named "CFBundleName" and change its value
      from "Clozure CL" to "CurrencyConverter". The application's name
      in the main menu bar should now appear correctly, as
      "CurrencyConverter". You may also want to change the other
      strings in the "InfoPlist.strings" file.</p>
    </div>

    <div class="nav">
      <p><a href="../../HOWTO.html">start</a>|<a href="conclusion.html">next</a></p>
    </div>


  </body>
</html>

